package com.sdcqjy.property.utils;

import android.content.SharedPreferences;

import com.sdcqjy.property.AppLL;

import static com.sdcqjy.property.MyConstants.NULL;

/**
 * Created by Administrator on 2017/3/26.
 */
public class UserConfig {
    private static final String UserMsg = "AppLL";
    private static final String Setting = "AppLL2";

    //>>>-----------------------------用户设置
    public static void setLogin(boolean isLogin) {
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(UserMsg, 0);
        sp.edit().putBoolean("isLogin", isLogin).apply();
    }

    public static boolean isLogin() {
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(UserMsg, 0);
        return sp.getBoolean("isLogin", false);
    }

    public static void setToken(String token) {
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(UserMsg, 0);
        sp.edit().putString("token", token).apply();
    }

    public static String getToken() {
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(UserMsg, 0);
        return sp.getString("token", NULL);
    }
    //<<<-----------------------------用户设置

    //>>>-----------------------------功能配置
    public static void setSwitchPush(boolean switchPush) {//推送功能
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(Setting, 0);
        sp.edit().putBoolean("switchPush", switchPush).apply();
    }

    public static boolean getSwitchPush() {
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(Setting, 0);
        return sp.getBoolean("switchPush", true);
    }

    public static void setSwitchSound(boolean switchSound) {//推送声音
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(Setting, 0);
        sp.edit().putBoolean("switchSound", switchSound).apply();
    }

    public static boolean getSwitchSound() {
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(Setting, 0);
        return sp.getBoolean("switchSound", true);
    }

    public static void setSwitchVibrat(boolean switchVibrat) {//推送震动
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(Setting, 0);
        sp.edit().putBoolean("switchVibrat", switchVibrat).apply();
    }

    public static boolean getSwitchVibrat() {
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(Setting, 0);
        return sp.getBoolean("switchVibrat", true);
    }

    public static void setSendCodeTime(long codeTime) {
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(Setting, 0);
        sp.edit().putLong("codeTime", codeTime).apply();
    }

    public static void setSendCodeTime2(long codeTime) {
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(Setting, 0);
        sp.edit().putLong("codeTime2", codeTime).apply();
    }

    public static long getSendCodeTime() {
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(Setting, 0);
        return sp.getLong("codeTime", 0);
    }

    public static long getSendCodeTime2() {
        SharedPreferences sp = AppLL.getAppLL().getSharedPreferences(Setting, 0);
        return sp.getLong("codeTime2", 0);
    }
    //<<<-----------------------------功能配置
}
